const $sql = require('../sqlfun');//sql语句
var models = require('../connectmysql');//数据库链接信息
var mysql = require('mysql');
var conn = mysql.createConnection(models.mysql);
conn.connect();

module.exports=(req, res) => {
  var sql = $sql.datames.addbbscomment;
  var params = req.body.dataop;
  console.log("sql",sql);
  console.log("params",params);
  var sql2=$sql.datames.bbscommentcount;
  var count;
  conn.query(sql2,function (err,data) {
    if(err){
      console.log(err);
    }else {
      count=data.length+1;
      console.log(data.length);
      conn.query(sql, [count,params.ctx,params.articlid,params.time,params.user], function(err, data) {
        if(err){
          var result={
            "status":"500",
            "message":"服务器错误"
          }
          console.log(result+err);
          res.send(result);
        }
        else {
          var result={
            "status":"200",
            "message":"success",
            //data:data
          }
          console.log(result);
          res.send(result);
        }
      })
    }
  })
}

